﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace AJWPFAdmin.Services.Migrations
{
    /// <inheritdoc />
    public partial class 北京接口定制 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<string>(
                name: "CarImage",
                table: "ShippingRecords",
                type: "longtext",
                nullable: true,
                comment: "车辆图片路径json数组字符串")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "InVideoCaptureFile",
                table: "ShippingRecords",
                type: "longtext",
                nullable: true,
                comment: "进厂录制视频文件路径")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "OutVideoCaptureFile",
                table: "ShippingRecords",
                type: "longtext",
                nullable: true,
                comment: "出厂录制视频文件路径")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<short>(
                name: "API",
                table: "EmiRiseRecords",
                type: "smallint",
                nullable: false,
                defaultValue: (short)0,
                comment: "来源接口");

            migrationBuilder.AddColumn<byte>(
                name: "Color",
                table: "EmiRiseRecords",
                type: "tinyint unsigned",
                nullable: false,
                defaultValue: (byte)0,
                comment: "号牌颜色");

            migrationBuilder.AddColumn<byte>(
                name: "EmissionStandard",
                table: "EmiRiseRecords",
                type: "tinyint unsigned",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "FuelType",
                table: "EmiRiseRecords",
                type: "varchar(50)",
                maxLength: 50,
                nullable: true,
                comment: "燃料类型")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "VIN",
                table: "EmiRiseRecords",
                type: "varchar(50)",
                maxLength: 50,
                nullable: true,
                comment: "车辆识别代码(VIN)")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<bool>(
                name: "EnableIO2Alarm",
                table: "Devices",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "是否启用IO2报警");

            migrationBuilder.AddColumn<int>(
                name: "IO2AlarmDelaySeconds",
                table: "Devices",
                type: "int",
                nullable: false,
                defaultValue: 0,
                comment: "IO2报警延迟秒数");

            migrationBuilder.AddColumn<string>(
                name: "CarImage",
                table: "Cars",
                type: "longtext",
                nullable: true,
                comment: "车辆图片路径json数组字符串")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IllegalVehicleRecords",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false),
                    CarNo = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "车牌号码")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Color = table.Column<byte>(type: "tinyint unsigned", nullable: false, comment: "号牌颜色"),
                    VIN = table.Column<string>(type: "longtext", nullable: true, comment: "车辆识别代码(VIN)")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    EntryTime = table.Column<DateTime>(type: "datetime(6)", maxLength: 50, nullable: true, comment: "进厂时间"),
                    DeliveryTime = table.Column<DateTime>(type: "datetime(6)", maxLength: 50, nullable: true, comment: "出厂时间"),
                    Reason = table.Column<string>(type: "longtext", nullable: true, comment: "违规通行原因")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Remark = table.Column<string>(type: "longtext", nullable: true, comment: "其他说明")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    API = table.Column<short>(type: "smallint", nullable: false, comment: "来源接口"),
                    CheckResult = table.Column<int>(type: "int", nullable: true, comment: "核查结果"),
                    FleetName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true, comment: "车队名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PId = table.Column<int>(type: "int", nullable: false),
                    CreateDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    UpdateDate = table.Column<DateTime>(type: "datetime(6)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IllegalVehicleRecords", x => x.Id);
                },
                comment: "违规车辆记录表")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.InsertData(
                table: "SystemConfigDictionaries",
                columns: new[] { "Key", "BooleanValue", "CreateDate", "DecimalValue", "IntValue", "StringValue", "UpdateDate" },
                values: new object[] { (short)1008, false, new DateTime(2024, 11, 26, 0, 0, 0, 0, DateTimeKind.Unspecified), 0m, 0, null, null });

            migrationBuilder.UpdateData(
                table: "SystemDictionaries",
                keyColumn: "Id",
                keyValue: 1L,
                column: "CreateDate",
                value: new DateTime(2025, 4, 14, 14, 59, 46, 464, DateTimeKind.Local).AddTicks(5995));

            migrationBuilder.UpdateData(
                table: "SystemDictionaries",
                keyColumn: "Id",
                keyValue: 2L,
                column: "CreateDate",
                value: new DateTime(2025, 4, 14, 14, 59, 46, 464, DateTimeKind.Local).AddTicks(6075));

            migrationBuilder.UpdateData(
                table: "SystemDictionaries",
                keyColumn: "Id",
                keyValue: 3L,
                column: "CreateDate",
                value: new DateTime(2025, 4, 14, 14, 59, 46, 464, DateTimeKind.Local).AddTicks(6111));
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "IllegalVehicleRecords");

            migrationBuilder.DeleteData(
                table: "SystemConfigDictionaries",
                keyColumn: "Key",
                keyValue: (short)1008);

            migrationBuilder.DropColumn(
                name: "CarImage",
                table: "ShippingRecords");

            migrationBuilder.DropColumn(
                name: "InVideoCaptureFile",
                table: "ShippingRecords");

            migrationBuilder.DropColumn(
                name: "OutVideoCaptureFile",
                table: "ShippingRecords");

            migrationBuilder.DropColumn(
                name: "API",
                table: "EmiRiseRecords");

            migrationBuilder.DropColumn(
                name: "Color",
                table: "EmiRiseRecords");

            migrationBuilder.DropColumn(
                name: "EmissionStandard",
                table: "EmiRiseRecords");

            migrationBuilder.DropColumn(
                name: "FuelType",
                table: "EmiRiseRecords");

            migrationBuilder.DropColumn(
                name: "VIN",
                table: "EmiRiseRecords");

            migrationBuilder.DropColumn(
                name: "EnableIO2Alarm",
                table: "Devices");

            migrationBuilder.DropColumn(
                name: "IO2AlarmDelaySeconds",
                table: "Devices");

            migrationBuilder.DropColumn(
                name: "CarImage",
                table: "Cars");

            migrationBuilder.UpdateData(
                table: "SystemDictionaries",
                keyColumn: "Id",
                keyValue: 1L,
                column: "CreateDate",
                value: new DateTime(2024, 12, 22, 21, 14, 2, 596, DateTimeKind.Local).AddTicks(3870));

            migrationBuilder.UpdateData(
                table: "SystemDictionaries",
                keyColumn: "Id",
                keyValue: 2L,
                column: "CreateDate",
                value: new DateTime(2024, 12, 22, 21, 14, 2, 596, DateTimeKind.Local).AddTicks(3890));

            migrationBuilder.UpdateData(
                table: "SystemDictionaries",
                keyColumn: "Id",
                keyValue: 3L,
                column: "CreateDate",
                value: new DateTime(2024, 12, 22, 21, 14, 2, 596, DateTimeKind.Local).AddTicks(3900));
        }
    }
}
